<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>聊天室</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
    <link href="/static/css/style.css" rel="stylesheet">
    <style>
        html, body {
            height: 100%;
            margin: 0;
            padding: 0;
        }
        .message {
            max-width: 70%;
        }
        .message.sent {
            margin-left: auto;
        }
        .message.sent .message-content {
            background-color: #007bff;
            color: white;
        }
        .message-content {
            background-color: #f8f9fa;
            border-radius: 1rem;
            padding: 0.5rem 1rem;
            word-break: break-word;
        }
        .user-item {
            cursor: default;
            transition: background-color 0.2s;
        }
        .user-item:hover {
            background-color: #f8f9fa;
        }
    </style>
</head>
<body>
    <div class="container-fluid h-100">
        <div class="row h-100">
            <!-- 左侧用户列表 -->
            <div class="col-md-3 border-end p-0">
                <div class="d-flex flex-column h-100">
                    <!-- 当前用户信息 -->
                    <div class="p-3 border-bottom">
                        <div class="d-flex align-items-center">
                            <div>
                                <h6 class="mb-0" id="currentUserName"></h6>
                                <small class="text-success">在线</small>
                            </div>
                            <button class="btn btn-link ms-auto" id="logoutBtn">
                                <i class="bi bi-box-arrow-right"></i>
                            </button>
                        </div>
                    </div>
                    <!-- 在线用户列表 -->
                    <div class="p-3 border-bottom bg-light">
                        <h6 class="mb-0">在线用户</h6>
                    </div>
                    <div class="flex-grow-1 overflow-auto" id="userList">
                        <!-- 用户列表将通过JavaScript动态添加 -->
                    </div>
                </div>
            </div>

            <!-- 右侧聊天区域 -->
            <div class="col-md-9 p-0">
                <div class="d-flex flex-column h-100">
                    <!-- 聊天室标题 -->
                    <div class="p-3 border-bottom">
                        <h5 class="mb-0">公共聊天室</h5>
                    </div>
                    <!-- 消息列表 -->
                    <div class="flex-grow-1 overflow-auto p-3" id="messageList">
                        <!-- 消息将通过JavaScript动态添加 -->
                    </div>
                    <!-- 输入区域 -->
                    <div class="border-top p-3">
                        <form id="messageForm" class="mb-0">
                            <div class="input-group">
                                <input type="text" class="form-control" id="messageInput" placeholder="输入消息...">
                                <button class="btn btn-primary" type="submit">发送</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 消息模板 -->
    <template id="messageTemplate">
        <div class="message mb-3">
            <div class="d-flex">
                <div class="flex-grow-1">
                    <div class="d-flex align-items-center mb-1">
                        <small class="fw-bold"></small>
                        <small class="text-muted ms-2"></small>
                    </div>
                    <div class="message-content"></div>
                </div>
            </div>
        </div>
    </template>

    <!-- 用户列表项模板 -->
    <template id="userItemTemplate">
        <div class="user-item p-3 border-bottom">
            <div class="d-flex align-items-center">
                <div class="flex-grow-1">
                    <h6 class="mb-0"></h6>
                    <small class="text-muted"></small>
                </div>
            </div>
        </div>
    </template>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="/static/js/chat.js"></script>
</body>
</html> 